<!DOCTYPE html>
<html lang="zh-CN">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/favicon.png">
  <link rel="icon" type="image/png" href="/blog/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  
  <meta name="theme-color" content="#35495e">
  <meta name="description" content="小菜头的博客，主要记录学习笔记，包含：html,css,javascript,jQuery,vue等">
  <meta name="author" content="A-cai">
  <meta name="keywords" content="html,css,javascript,jQuery,vue">
  <title>retina屏幕1px边框问题 - A-cai的blog</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/blog/lib/hint/hint.min.css" />

  
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/atom-one-dark.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">


<link  rel="stylesheet" href="/blog/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/blog/js/utils.js" ></script>
<meta name="generator" content="Hexo 4.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/blog/">&nbsp;<strong>A-cai的学习笔记</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/blog/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2020-06-26 14:05">
      2020年6月26日 下午
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.4k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      19
       分钟
    </span>
  

  
  
    
      <!-- 不蒜子统计文章PV -->
      <span id="busuanzi_container_page_pv" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="busuanzi_value_page_pv"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <div class="post-content mx-auto" id="post">
            
              <p class="note note-info">
                
                  本文最后更新于：2020年3月17日 晚上
                
              </p>
            
            <article class="markdown-body">
              <h1 id="7-种方法解决移动端-Retina-屏幕-1px-边框问题"><a href="#7-种方法解决移动端-Retina-屏幕-1px-边框问题" class="headerlink" title="7 种方法解决移动端 Retina 屏幕 1px 边框问题"></a>7 种方法解决移动端 Retina 屏幕 1px 边框问题</h1><h3 id="造成边框变粗的原因"><a href="#造成边框变粗的原因" class="headerlink" title="造成边框变粗的原因"></a>造成边框变粗的原因</h3><p>其实这个原因很简单，因为css中的1px并不等于移动设备的1px，这些由于不同的手机有不同的像素密度。在window对象中有一个devicePixelRatio属性，他可以反应css中的像素与设备的像素比。</p>
<blockquote>
<p>devicePixelRatio的官方的定义为：设备物理像素和设备独立像素的比例，也就是 devicePixelRatio = 物理像素 / 独立像素。</p>
</blockquote>
<h3 id="解决边框变粗的6种办法"><a href="#解决边框变粗的6种办法" class="headerlink" title="解决边框变粗的6种办法"></a>解决边框变粗的6种办法</h3><h1 id="1、0-5px边框"><a href="#1、0-5px边框" class="headerlink" title="1、0.5px边框"></a>1、0.5px边框</h1><p>在2014年的 WWDC，“设计响应的Web体验” 一讲中，Ted O’Connor 讲到关于“retinahairlines”（retina 极细的线）：在retina屏上仅仅显示1物理像素的边框，开发者应该如何处理呢。</p>
<p>他们曾介绍到 iOS 8 和 OS X Yosemite 即将支持 0.5px 的边框：</p>
<p><img src="https://user-gold-cdn.xitu.io/2016/12/12/f6ad282f2019bbbb30c9ac84902fcb02?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" srcset="/blog/img/loading.gif" alt="img"></p>
<p>0.5px边框</p>
<p>额的神呐！so easy! 果真如此吗？这样还不够（WWDC幻灯片通常是“唬人”的），但是相差不多。</p>
<p>问题是 retina 屏的浏览器可能不认识0.5px的边框，将会把它解释成0px，没有边框。包括 iOS 7 和之前版本，OS X Mavericks 及以前版本，还有 Android 设备。</p>
<p><strong>解决方案：</strong><br>解决方案是通过 JavaScript 检测浏览器能否处理0.5px的边框，如果可以，给html标签元素添加个class。</p>
<div class="hljs"><pre><code class="hljs dart"><span class="hljs-keyword">if</span> (<span class="hljs-built_in">window</span>.devicePixelRatio &amp;&amp; devicePixelRatio &gt;= <span class="hljs-number">2</span>) &#123;
<span class="hljs-keyword">var</span> testElem = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">'div'</span>);
testElem.style.border = <span class="hljs-string">'.5px solid transparent'</span>;
<span class="hljs-built_in">document</span>.body.appendChild(testElem);
<span class="hljs-keyword">if</span> (testElem.offsetHeight == <span class="hljs-number">1</span>) &#123;
<span class="hljs-built_in">document</span>.<span class="hljs-built_in">querySelector</span>(<span class="hljs-string">'html'</span>).classList.add(<span class="hljs-string">'hairlines'</span>);
&#125;
<span class="hljs-built_in">document</span>.body.removeChild(testElem);
&#125;
<span class="hljs-comment">// 脚本应该放在内，如果在里面运行，需要包装 $(document).ready(function() &#123;&#125;)</span></code></pre></div>

<p>然后，极细的边框样式就容易了：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-tag">div</span> &#123;
<span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#bbb</span>;
&#125;
<span class="hljs-selector-class">.hairlines</span> <span class="hljs-selector-tag">div</span> &#123;
<span class="hljs-attribute">border-width</span>: <span class="hljs-number">0.5px</span>;
&#125;</code></pre></div>



<h2 id="2、使用border-image实现"><a href="#2、使用border-image实现" class="headerlink" title="2、使用border-image实现"></a>2、使用border-image实现</h2><p>准备一张符合你要求的border-image：</p>
<p><img src="https://user-gold-cdn.xitu.io/2016/12/12/ca699bb52b53f3014edce2771051b6f2?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" srcset="/blog/img/loading.gif" alt="img"></p>
<p>底部边框</p>
<p>样式设置：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.border-bottom-1px</span> &#123;
<span class="hljs-attribute">border-width</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">1px</span> <span class="hljs-number">0</span>;
<span class="hljs-attribute">-webkit-border-image</span>: <span class="hljs-built_in">url</span>(linenew.png) <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">2</span> <span class="hljs-number">0</span> stretch;
<span class="hljs-attribute">border-image</span>: <span class="hljs-built_in">url</span>(linenew.png) <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">2</span> <span class="hljs-number">0</span> stretch;
&#125;</code></pre></div>

<p>上文是把border设置在边框的底部，所以使用的图片是2px高，上部的1px颜色为透明，下部的1px使用视觉规定的border的颜色。如果边框底部和顶部同时需要border，可以使用下面的border-image：</p>
<p><img src="https://user-gold-cdn.xitu.io/2016/12/12/99a1fd3191a7c819f9ac6fa55811a816?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" srcset="/blog/img/loading.gif" alt="img"></p>
<p>上下边框</p>
<p>样式设置：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.border-image-1px</span> &#123;
<span class="hljs-attribute">border-width</span>: <span class="hljs-number">1px</span> <span class="hljs-number">0</span>;
<span class="hljs-attribute">-webkit-border-image</span>: <span class="hljs-built_in">url</span>(linenew.png) <span class="hljs-number">2</span> <span class="hljs-number">0</span> stretch;
<span class="hljs-attribute">border-image</span>: <span class="hljs-built_in">url</span>(linenew.png) <span class="hljs-number">2</span> <span class="hljs-number">0</span> stretch;
&#125;</code></pre></div>

<p>到目前为止，我们已经能在iphone上展现1px border的效果了。但是我们发现这样的方法在非视网膜屏上会出现border显示不出来的现象，于是使用Media Query做了一些兼容，样式设置如下：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.border-image-1px</span> &#123;
<span class="hljs-attribute">border-bottom</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#666</span>;
&#125;
<span class="hljs-keyword">@media</span> <span class="hljs-keyword">only</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">-webkit-min-device-pixel-ratio:</span> <span class="hljs-number">2</span>) &#123;
<span class="hljs-selector-class">.border-image-1px</span> &#123;
<span class="hljs-attribute">border-bottom</span>: none;
<span class="hljs-attribute">border-width</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">1px</span> <span class="hljs-number">0</span>;
<span class="hljs-attribute">-webkit-border-image</span>: <span class="hljs-built_in">url</span>(../img/linenew.png) <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">2</span> <span class="hljs-number">0</span> stretch;
<span class="hljs-attribute">border-image</span>: <span class="hljs-built_in">url</span>(../img/linenew.png) <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">2</span> <span class="hljs-number">0</span> stretch;
&#125;
&#125;</code></pre></div>

<p><strong>缺点：</strong></p>
<ul>
<li>修改颜色麻烦, 需要替换图片</li>
<li>圆角需要特殊处理，并且边缘会模糊</li>
</ul>
<h3 id="3、使用background-image实现"><a href="#3、使用background-image实现" class="headerlink" title="3、使用background-image实现"></a>3、使用background-image实现</h3><p>background-image 跟border-image的方法一样，你要先准备一张符合你要求的图片。然后将边框模拟在背景上。<br>样式设置：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.background-image-1px</span> &#123;
<span class="hljs-attribute">background</span>: <span class="hljs-built_in">url</span>(../img/line.png) repeat-x left bottom;
<span class="hljs-attribute">-webkit-background-size</span>: <span class="hljs-number">100%</span> <span class="hljs-number">1px</span>;
<span class="hljs-attribute">background-size</span>: <span class="hljs-number">100%</span> <span class="hljs-number">1px</span>;
&#125;</code></pre></div>

<p><strong>优点：</strong></p>
<p><strong>缺点：</strong></p>
<ul>
<li>修改颜色麻烦, 需要替换图片</li>
<li>圆角需要特殊处理，并且边缘会模糊</li>
</ul>
<h3 id="4、多背景渐变实现"><a href="#4、多背景渐变实现" class="headerlink" title="4、多背景渐变实现"></a>4、多背景渐变实现</h3><p>与background-image方案类似，只是将图片替换为css3渐变。设置1px的渐变背景，50%有颜色，50%透明。<br>样式设置：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.background-gradient-1px</span> &#123;
<span class="hljs-attribute">background</span>:
<span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">180deg</span>, black, black <span class="hljs-number">50%</span>, transparent <span class="hljs-number">50%</span>) top left / <span class="hljs-number">100%</span> <span class="hljs-number">1px</span> no-repeat,
<span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">90deg</span>, black, black <span class="hljs-number">50%</span>, transparent <span class="hljs-number">50%</span>) top right / <span class="hljs-number">1px</span> <span class="hljs-number">100%</span> no-repeat,
<span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">0</span>, black, black <span class="hljs-number">50%</span>, transparent <span class="hljs-number">50%</span>) bottom right / <span class="hljs-number">100%</span> <span class="hljs-number">1px</span> no-repeat,
<span class="hljs-built_in">linear-gradient</span>(-<span class="hljs-number">90deg</span>, black, black <span class="hljs-number">50%</span>, transparent <span class="hljs-number">50%</span>) bottom left / <span class="hljs-number">1px</span> <span class="hljs-number">100%</span> no-repeat;
&#125;
<span class="hljs-comment">/* 或者 */</span>
<span class="hljs-selector-class">.background-gradient-1px</span>&#123;
<span class="hljs-attribute">background</span>: <span class="hljs-built_in">-webkit-gradient</span>(linear, left top, left bottom, color-stop(.<span class="hljs-number">5</span>, transparent), <span class="hljs-built_in">color-stop</span>(.<span class="hljs-number">5</span>, #c8c7cc), <span class="hljs-built_in">to</span>(#c8c7cc)) left bottom repeat-x;
<span class="hljs-attribute">background-size</span>: <span class="hljs-number">100%</span> <span class="hljs-number">1px</span>;
&#125;</code></pre></div>

<h3 id="5、使用box-shadow模拟边框"><a href="#5、使用box-shadow模拟边框" class="headerlink" title="5、使用box-shadow模拟边框"></a>5、使用box-shadow模拟边框</h3><p>利用css 对阴影处理的方式实现0.5px的效果<br>样式设置：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.box-shadow-1px</span> &#123;
<span class="hljs-attribute">box-shadow</span>: inset <span class="hljs-number">0px</span> -<span class="hljs-number">1px</span> <span class="hljs-number">1px</span> -<span class="hljs-number">1px</span> <span class="hljs-number">#c8c7cc</span>;
&#125;</code></pre></div>

<p><strong>优点：</strong></p>
<p><strong>缺点：</strong></p>
<h3 id="6、viewport-rem-实现"><a href="#6、viewport-rem-实现" class="headerlink" title="6、viewport + rem 实现"></a>6、viewport + rem 实现</h3><p>同时通过设置对应viewport的rem基准值，这种方式就可以像以前一样轻松愉快的写1px了。<br>在devicePixelRatio = 2 时，输出viewport：</p>
<div class="hljs"><pre><code class="hljs autohotkey">在devicePixelRatio = <span class="hljs-number">3</span> 时，输出viewport：
​```html</code></pre></div>

<p>这种兼容方案相对比较完美，适合新的项目，老的项目修改成本过大。<br>对于这种方案，可以看看<a href="https://github.com/amfe/article/issues/17" target="_blank" rel="noopener">《使用Flexible实现手淘H5页面的终端适配》</a><br><strong>优点：</strong></p>
<p><strong>缺点：</strong></p>
<h3 id="7、伪类-transform-实现"><a href="#7、伪类-transform-实现" class="headerlink" title="7、伪类 + transform 实现"></a>7、伪类 + transform 实现</h3><p>对于老项目，有没有什么办法能兼容1px的尴尬问题了，个人认为伪类+transform是比较完美的方法了。原理是把原先元素的 border 去掉，然后利用 :before 或者 :after 重做 border ，并 transform 的 scale 缩小一半，原先的元素相对定位，新做的 border 绝对定位。</p>
<p>单条border样式设置：</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.scale-1px</span>&#123;
<span class="hljs-attribute">position</span>: relative;
<span class="hljs-attribute">border</span>:none;
&#125;
<span class="hljs-selector-class">.scale-1px</span><span class="hljs-selector-pseudo">:after</span>&#123;
<span class="hljs-attribute">content</span>: <span class="hljs-string">''</span>;
<span class="hljs-attribute">position</span>: absolute;
<span class="hljs-attribute">bottom</span>: <span class="hljs-number">0</span>;
<span class="hljs-attribute">background</span>: <span class="hljs-number">#000</span>;
<span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;
<span class="hljs-attribute">height</span>: <span class="hljs-number">1px</span>;
<span class="hljs-attribute">-webkit-transform</span>: <span class="hljs-built_in">scaleY</span>(<span class="hljs-number">0.5</span>);
<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scaleY</span>(<span class="hljs-number">0.5</span>);
<span class="hljs-attribute">-webkit-transform-origin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;
<span class="hljs-attribute">transform-origin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;
&#125;</code></pre></div>

<p>四条boder样式设置:</p>
<div class="hljs"><pre><code class="hljs css"><span class="hljs-selector-class">.scale-1px</span>&#123;
<span class="hljs-attribute">position</span>: relative;
<span class="hljs-attribute">margin-bottom</span>: <span class="hljs-number">20px</span>;
<span class="hljs-attribute">border</span>:none;
&#125;
<span class="hljs-selector-class">.scale-1px</span><span class="hljs-selector-pseudo">:after</span>&#123;
<span class="hljs-attribute">content</span>: <span class="hljs-string">''</span>;
<span class="hljs-attribute">position</span>: absolute;
<span class="hljs-attribute">top</span>: <span class="hljs-number">0</span>;
<span class="hljs-attribute">left</span>: <span class="hljs-number">0</span>;
<span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#000</span>;
<span class="hljs-attribute">-webkit-box-sizing</span>: border-box;
<span class="hljs-attribute">box-sizing</span>: border-box;
<span class="hljs-attribute">width</span>: <span class="hljs-number">200%</span>;
<span class="hljs-attribute">height</span>: <span class="hljs-number">200%</span>;
<span class="hljs-attribute">-webkit-transform</span>: <span class="hljs-built_in">scale</span>(<span class="hljs-number">0.5</span>);
<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scale</span>(<span class="hljs-number">0.5</span>);
<span class="hljs-attribute">-webkit-transform-origin</span>: left top;
<span class="hljs-attribute">transform-origin</span>: left top;
&#125;</code></pre></div>

<p>最好在使用前也判断一下，结合 JS 代码，判断是否 Retina 屏：</p>
<div class="hljs"><pre><code class="hljs dart"><span class="hljs-keyword">if</span>(<span class="hljs-built_in">window</span>.devicePixelRatio &amp;&amp; devicePixelRatio &gt;= <span class="hljs-number">2</span>)&#123;
<span class="hljs-built_in">document</span>.<span class="hljs-built_in">querySelector</span>(<span class="hljs-string">'ul'</span>).className = <span class="hljs-string">'scale-1px'</span>;
&#125;</code></pre></div>

<p><strong>优点：</strong></p>
<ul>
<li>所有场景都能满足</li>
<li>支持圆角(伪类和本体类都需要加border-radius)</li>
</ul>
<p><strong>缺点：</strong></p>
<ul>
<li>对于已经使用伪类的元素(例如clearfix)，可能需要多层嵌套</li>
</ul>

            </article>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" target="_blank" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <div class="post-prev col-6">
                    
                    
                      <a href="/blog/2020/06/26/BFC%E3%80%81IFC%E3%80%81GFC%E5%92%8CFFC/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">BFC、IFC、GFC和FFC</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </div>
                  <div class="post-next col-6">
                    
                    
                      <a href="/blog/2020/06/26/%E8%A6%86%E7%9B%96%E5%85%83%E7%B4%A0%E5%AE%BD%E5%BA%A6/">
                        <span class="hidden-mobile">覆盖元素宽度</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </div>
                </div>
              
            </div>

            
              <!-- Comments -->
              <div class="comments" id="comments">
                
                

              </div>
            
          </div>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    

    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/debouncer.js" ></script>
<script  src="/blog/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/blog/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/blog/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "retina屏幕1px边框问题&nbsp;",
      ],
      cursorChar: "|",
      typeSpeed: 70,
      loop: true,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/blog/js/local-search.js" ></script>
  <script>
    var path = "/blog/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>







  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  













</body>
</html>
